﻿using System.Data.EntityClient;

namespace LayeredArchitectureSample.DataAccess
{
    public class DatabaseContextFactory : IDatabaseContextFactory
    {
        public LayeredSampleDataModel CreateDatabaseContext()
        {
            var entityConnectionStringBuilder = new EntityConnectionStringBuilder();

            entityConnectionStringBuilder.Provider = "System.Data.SqlClient";

            // search all loaded assemblies for the metadata info
            entityConnectionStringBuilder.Metadata = "res://*";

            entityConnectionStringBuilder.ProviderConnectionString =
                @"Data Source=.\SQLEXPRESS;Initial Catalog=LayeredSampleDatabase;Integrated Security=True;MultipleActiveResultSets=True";

            return new LayeredSampleDataModel(entityConnectionStringBuilder.ConnectionString);
        }
    }
}